/*
 *
 *  This file is part of Cfu
 *
 *  Cfu is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  Cfu is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with Cfu. If not, see <http://www.gnu.org/licenses/>.
 *
 *  configuration.hpp - william le ferrand (william@corefarm.com) 29/04/2010 15:30
 *
 */


#ifndef CFU_CONFIGURATION_HPP_
#define CFU_CONFIGURATION_HPP_

#include <QObject>

class configuration_t : public QObject
{
  Q_OBJECT 
  Q_PROPERTY(QString login READ getLogin WRITE setLogin NOTIFY loginChanged USER true)
  Q_PROPERTY(QString password READ getPassword WRITE setPassword NOTIFY passwordChanged USER true)
  Q_PROPERTY(QString server READ getServer WRITE setServer USER true)
  

 public: 
    configuration_t(QString &confFile); 
  
  inline const QString &getLogin() const          { return _login; }
  inline const QString &getPassword() const       { return _password; }
  inline const QString &getServer() const         { return _server; }
  void setLogin(const QString &login);
  void setPassword(const QString &password);
  inline void setServer(const QString &server)    { _server = server; }
       
 public slots:
  void saveConfigurationToFile();
  
  signals:
  void loginChanged(const QString &newValue);
  void passwordChanged(const QString &newValue);

        
 private:
  bool _tryLoadConfigurationFile();
  bool _hasProperty(const QString &propertyName);

 private:
  QString _login;
  QString _password;
  QString _server;

  QString _confFile;
  bool _firstStart; 
};





#endif
